//
//  MineHeadView.m
//  ZJControlsClass
//
//  Created by mac on 2024/11/24.
//

#import "MineHeadView.h"


@interface MineHeadView ()

@property (nonatomic,strong) UIImageView * follewImg;
@property (nonatomic,strong) UIImageView * iconImg;
@property (nonatomic,strong) UILabel * nameLabel;
@property (nonatomic,strong) UILabel * numberLabel;
@property (nonatomic,strong) UIImageView * rightImg;

@property (nonatomic,strong) UILabel * approveLabel;
@property (nonatomic,strong) UILabel * moneyLabel;
@property (nonatomic,strong) UILabel * backMoneyLabel;
@property (nonatomic,strong) UIView * bottomView;



@end


@implementation MineHeadView

- (instancetype)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    
    if (self) {
        [self configUI];
    }
    
    return self;
}

-(void)configUI{
    
    [self addSubview:self.follewImg];
    [self.follewImg addSubview:self.iconImg];
    [self.follewImg addSubview:self.nameLabel];
    [self.follewImg addSubview:self.numberLabel];
    [self.follewImg addSubview:self.rightImg];
    [self.follewImg addSubview:self.approveLabel];
    [self.follewImg addSubview:self.moneyLabel];
    [self.follewImg addSubview:self.backMoneyLabel];
    [self addSubview:self.bottomView];
    
    [self.follewImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.bottom.equalTo(self);
    }];
    
    [self.iconImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.follewImg).with.offset(ALIGN_WIDTH_PT(12));
        make.top.equalTo(self.follewImg).with.offset(ALIGN_HEIGHT_PT(18));
        make.size.equalTo(@(CGSizeMake(ALIGN_WIDTH_PT(64), ALIGN_WIDTH_PT(64))));
    }];
    
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.iconImg.mas_right).with.offset(ALIGN_WIDTH_PT(8));
        make.top.equalTo(self.follewImg).with.offset(ALIGN_HEIGHT_PT(28.5));
    }];
    
    [self.numberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.nameLabel.mas_left);
        make.top.equalTo(self.nameLabel.mas_bottom).with.offset(ALIGN_HEIGHT_PT(5));
    }];
    
    [self.rightImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.iconImg.mas_centerY);
        make.right.equalTo(self.follewImg).with.offset(-ALIGN_WIDTH_PT(28.5));
        make.size.equalTo(@(CGSizeMake(ALIGN_WIDTH_PT(8), ALIGN_HEIGHT_PT(12))));
    }];
    
    [self.approveLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.follewImg);
        make.top.equalTo(self.iconImg.mas_bottom).with.offset(ALIGN_HEIGHT_PT(16.5));
        make.width.equalTo(@(SCREEN_WIDTH / 3));
    }];
    
    [self.moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.approveLabel.mas_right);
        make.top.equalTo(self.iconImg.mas_bottom).with.offset(ALIGN_HEIGHT_PT(16.5));
        make.width.equalTo(@(SCREEN_WIDTH / 3));
    }];
    
    [self.backMoneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.moneyLabel.mas_right);
        make.top.equalTo(self.iconImg.mas_bottom).with.offset(ALIGN_HEIGHT_PT(16.5));
        make.width.equalTo(@(SCREEN_WIDTH / 3));
    }];
    
    [self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self);
        make.bottom.equalTo(self.mas_bottom).with.offset(ALIGN_HEIGHT_PT(10));
        make.height.equalTo(@(ALIGN_HEIGHT_PT(20)));
    }];
    
}



#pragma mark -- 懒加载
-(UIImageView *)follewImg {
    if (!_follewImg){
        _follewImg = [UIImageView new];
        _follewImg.image = [UIImage imageNamed:@"Mask group-1"];
    }
    return _follewImg;
}

-(UIImageView *)iconImg{
    if (!_iconImg){
        _iconImg = [UIImageView new];
//        NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
//        if ([defaults valueForKey:@"avatar"]){
//            _iconImg.image = [UIImage imageNamed:[defaults valueForKey:@"avatar"]];
//        }else{
            _iconImg.image = [UIImage imageNamed:@"默认头像"];
//        }
        _iconImg.layer.cornerRadius = 6;
        _iconImg.layer.masksToBounds = YES;
    }
    return _iconImg;
}

-(UILabel *)nameLabel{
    if (!_nameLabel){
        _nameLabel = [UILabel new];
        NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
        _nameLabel.text = [defaults valueForKey:@"nickname"];
        _nameLabel.textAlignment = NSTextAlignmentLeft;
        _nameLabel.font = FONT14;
        _nameLabel.textColor = [UIColor blackColor];
    }
    return _nameLabel;
}

-(UILabel *)numberLabel{
    if (!_numberLabel){
        _numberLabel = [UILabel new];
        _numberLabel.text = @"12分";
        _numberLabel.textAlignment = NSTextAlignmentLeft;
        _numberLabel.font = FONT12;
        _numberLabel.textColor = [UIColor blackColor];
    }
    return _numberLabel;
}

-(UIImageView *)rightImg{
    if (!_rightImg){
        _rightImg = [UIImageView new];
        _rightImg.image = [UIImage imageNamed:@"向右箭头"];
    }
    return _rightImg;
}

-(UILabel *)approveLabel{
    if (!_approveLabel){
        _approveLabel = [UILabel new];
//        _approveLabel.text = @"审核中 \n12";
        _approveLabel.textAlignment = NSTextAlignmentCenter;
        _approveLabel.font = FONT14;
        _approveLabel.textColor = [UIColor blackColor];
        _approveLabel.numberOfLines = 2;
    }
    return _approveLabel;
}

-(UILabel *)moneyLabel{
    if (!_moneyLabel){
        _moneyLabel = [UILabel new];
//        _moneyLabel.text = @"待缴费 \n102";
        _moneyLabel.textAlignment = NSTextAlignmentCenter;
        _moneyLabel.font = FONT16;
        _moneyLabel.textColor = [UIColor blackColor];
        _moneyLabel.numberOfLines = 2;
    }
    return _moneyLabel;
}

-(UILabel *)backMoneyLabel{
    if (!_backMoneyLabel){
        _backMoneyLabel = [UILabel new];
//        _backMoneyLabel.text = @"待退费 \n12";
        _backMoneyLabel.textAlignment = NSTextAlignmentCenter;
        _backMoneyLabel.font = FONT16;
        _backMoneyLabel.textColor = [UIColor blackColor];
        _backMoneyLabel.numberOfLines = 2;
    }
    return _backMoneyLabel;
}

-(UIView *)bottomView{
    if (!_bottomView){
        _bottomView = [UIView new];
        _bottomView.backgroundColor = [UIColor whiteColor];
        _bottomView.layer.cornerRadius = 10;
        _bottomView.layer.masksToBounds = YES;
    }
    return _bottomView;
}



@end
